//
//  PaperCollectionReusableView.m
//  ZYOnlineSchool
//
//  Created by 毕武侠 on 2017/3/9.
//  Copyright © 2017年 bwx. All rights reserved.
//

#import "PaperCollectionReusableView.h"
#import "NSString+Size.h"

@interface PaperCollectionReusableView ()

@property (nonatomic, strong) UILabel *partLab;             // 模块部分
@property (nonatomic, strong) UILabel *titleLab;            // 模块标题
@property (nonatomic, strong) UILabel *contentLab;          // 模块标题

@end

@implementation PaperCollectionReusableView

- (void)bindModel:(PaperModuleModel *)model {
    if (_titleLab == nil) {
        [self setupConfigure];
    }
    
    self.partLab.text = model.abbreviations;
    self.titleLab.text = model.module_name;
    self.contentLab.text = model.bewrite;
    CGSize size = [model.bewrite textSizeIn:CGSizeMake(SCREEN_WIDTH - 72.0, 500) font:[UIFont systemFontOfSize:15]];
    //[self.contentLab sizeToFit];
    CGRect frame = self.contentLab.frame;
    frame.size = size;
    self.contentLab.frame = frame;
    self.contentLab.numberOfLines = 0;
}

- (void)setupConfigure {
    // 加载顶部topView
    [self addSubview:self.partLab];
    [self addSubview:self.titleLab];
    [self addSubview:self.contentLab];
}

#pragma mark - getter

- (UILabel *)partLab {
    if (_partLab == nil) {
        _partLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 16, SCREEN_WIDTH, 40.0)];
        _partLab.textColor = MainThemeColor;
        _partLab.textAlignment = NSTextAlignmentCenter;
    }
    return _partLab;
}

- (UILabel *)titleLab {
    if (_titleLab == nil) {
        _titleLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 60, SCREEN_WIDTH, 32.0f)];
        _titleLab.textColor = [UIColor darkGrayColor];
        _titleLab.textAlignment = NSTextAlignmentCenter;
        _titleLab.font = [UIFont systemFontOfSize:16];
    }
    return _titleLab;
}

- (UILabel *)contentLab {
    if (_contentLab == nil) {
        _contentLab = [[UILabel alloc] initWithFrame:CGRectMake(36, 100.0f, SCREEN_WIDTH - 72.0, 32.0f)];
        _contentLab.textColor = [UIColor darkGrayColor];
        _contentLab.textAlignment = NSTextAlignmentCenter;
        _contentLab.numberOfLines = 0;
        _contentLab.font = [UIFont systemFontOfSize:15];
    }
    return _contentLab;
}

@end
